

import * as tt2 from "../ttapi_layer2/ttlayer2.js";
import { BattleList } from "./model/battlelist.js";


export class UserData {
    scene: tt2.QFrame_Scene<UserData>
    battlelist: BattleList;
    async LoadAsync(): Promise<void> {
        this.battlelist = new BattleList();
        await this.battlelist.LoadAsync("battlelist.json");
    }
}
export abstract class UserState implements tt2.QFrame_IState<UserData>
{
    protected app: tt2.QFrame_App<UserData>
    protected userdata: UserData;

    OnInit(statemgr: tt2.QFrame_App<UserData>): void {
        this.app = statemgr;
        this.userdata = this.app.getUserData();
        if (this.userdata.scene == null) {
            let screensize = new tt2.QFrame_ScreenSize();
            screensize.mode = tt2.QFrame_ScreenMode.LimitRadioScalePixel;
            screensize.minWidth = screensize.maxWidth = 240;
            screensize.minHeight = 360;
            screensize.maxHeight = 480;
            this.userdata.scene = new tt2.QFrame_Scene<UserData>(this.app, screensize);
        }


    }

    OnExit(): void {

    }
    OnUpdate(delta: number): void {
        this.app.getUserData().scene.OnUpdate(delta);
    }
    OnRender(): void {
        this.app.getUserData().scene.OnRender();
    }
}
